package com.leanit.pmc.center.user;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by admin on 2016/3/30.
 */
@Repository
public interface CenterDao {

    @Select("SELECT identityNo FROM SYS_USER_IDENTITY WHERE loginName = #{loginName} and rownum=1")
    String getIdNo(@Param("loginName") String loginName);

    @Insert("Insert Into SYS_USER_IDENTITY (loginName) values(#{loginName})")
    void insertIdNo(@Param("loginName") String loginName);

    @Update("UPDATE SYS_USER_IDENTITY set identityNo=#{identityNo} where loginName=#{loginName}")
    void updateIdNo(@Param("loginName") String loginName, @Param("identityNo") String identityNo);

    @Update("UPDATE SYS_USER set cn_name=#{cnName},mobile_phone_number=#{phoneNo} where USERNAME=#{loginName}")
    void updateUserName(@Param("loginName") String loginName, @Param("cnName") String cnName,
                        @Param("phoneNo") String phoneNo);


    @Select("SELECT cn_name,mobile_phone_number FROM SYS_USER WHERE USERNAME = #{loginName} and rownum=1")
    List getUserInfo(@Param("loginName") String loginName);

}
